package com.bdqn.role;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {
    @org.junit.jupiter.api.Test
    public void test() {
        // 通过ClassPathXmlApplicationContext显式地实例化Spring的上下文
        ApplicationContext context = new ClassPathXmlApplicationContext(
                "applicationContext.xml");
        // 通过Greeting bean的id来获取bean的实例
        Greeting luFeiSay = (Greeting) context.getBean("luFeiSay");
        Greeting zhuGeLiangSay = (Greeting) context.getBean("zhuGeLiangSay");
        // 执行sayGreeting()方法
        luFeiSay.sayGreeting();
        zhuGeLiangSay.sayGreeting();
    }
}
